﻿using System;
using System.Linq;
using FollowMe.Model;
using FollowMe.Infrastructure.UnitOfWork;

namespace FollowMe.Repository
{
    /// <summary>
    /// The Member Repo
    /// </summary>
    public class MemberRepository : Repository<Member, Guid>, IMemberRepository
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberRepository"/> class.
        /// </summary>
        /// <param name="fm">The fm.</param>
        public MemberRepository(IContext fm)
            : base(fm)
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="MemberRepository"/> class.
        /// </summary>
        public MemberRepository() { }

        /// <summary>
        /// Finds a collection of users based on (string) username/email.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns>A collection of members</returns>
        public IQueryable<Member> FindBy(String userName)
        {
            return GetObjectSet().Where<Member>(u => u.UserName.Contains(userName));
        }
    }
}
